/**
 * Top Message/Notification
 */
define(['jquery', 'bootstrap'], function($) {
	var TopHeader, viewport = VAM.getViewport();
	TopHeader = (function () {
		function TopHeader () {
			// this.topMessage();
			// this.userInfo();
			this.navSearch();
			// this.navBar();
			// this.navSwitch();
		}
		TopHeader.prototype.topMessage = function() {
			var $topMsg = $('#top-menu-message'),
				$topNotice = $('#top-menu-notice'),
				webroot = $('#current-webroot').val();
		};

		TopHeader.prototype.userInfo = function() {
			var $userInfo = $('#top-user-info'), 
				$dropdownMenu = $userInfo.next('ul.dropdown-menu');
		};

		// Header nav search
		TopHeader.prototype.navSearch = function() {
			var $navSearch = $('#nav-header-search'),
				originWidth = $navSearch.outerWidth();
			$navSearch.on('focus', function(evt) {
				evt.preventDefault();
				if (viewport.width >= 992) {
					$navSearch.animate({
						width: 200},
						'fast',
						'swing', function() {
					});
				}
			})
			.on('blur', function(evt) {
				evt.preventDefault();
				if (viewport.width >= 992) {
					$navSearch.animate({
						width: originWidth},
						'fast',
						'swing', function() {
					});
				};
			});
		};

		// Header nav active.
		TopHeader.prototype.navBar = function () {
			var $currentHeader = $('#current-header'),
			$currentNav = $('#current-navigator'),
			$headerNav = $('.header-navbar > li'),
			$subNav = $headerNav.find('.sub-nav li'),
			currHeader = $currentHeader.val(),
			currSubNav = $currentNav.val();

			// console.log($subNav);
			$headerNav.removeClass('active');
			$subNav.removeClass('active');
			$('#'+currHeader).addClass('active');
			$('#'+currSubNav).addClass('active');
		};

		// Header nav switch.
		TopHeader.prototype.navSwitch = function () {
			var $headerNav = $('.header-navbar > li');

			// Header Nav slide up/down.
			$headerNav.on({
				mouseenter: function(evt) {
					var $me = $(this),
					$subNav = $me.find('.sub-nav');
					$subNav.stop(true, true).slideDown();
				},
				mouseleave: function (evt) {
					var $me = $(this),
					$subNav = $me.find('.sub-nav');
					$subNav.stop(true, true).slideUp();
				}
			});
		};

		return TopHeader;
	})();

	return new TopHeader();
});